//
//  ViewController.m
//  MyBlock
//
//  Created by yuanjiang on 2016/11/24.
//  Copyright © 2016年 YuanJiang. All rights reserved.
//

#import "ViewController.h"
#import "VC1.h"
@interface ViewController ()

@property(nonatomic,strong) UIButton *btn;

@end


@implementation ViewController

-(void)viewDidLoad
{
    [super viewDidLoad];
    
    //创建一个button
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:CGRectMake(130, 130, 130, 130)];
    [button setTitle:@"这是一个按钮" forState:UIControlStateNormal];
    [button setBackgroundColor: [UIColor redColor]];
    [button addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
    self.btn = button;
    [self.view addSubview:button];
    
    
    
}

- (void)clickAction:(UIButton *)sender
{
    VC1 *vc = [[VC1 alloc] init];
    __weak typeof(self)weakself = self;
    vc.passvalueblock = ^(NSString *value) {
        [weakself.btn setTitle:value forState:UIControlStateNormal];
    };
    
    //或者
//    [vc setPassvalueblock:^(NSString *value) {
//        //do something
//    }];
    [self.navigationController pushViewController:vc animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
